package didi.hcp.questionrobot.service.impl;

import didi.hcp.questionrobot.bo.CategoryBO;
import didi.hcp.questionrobot.entity.Category;
import didi.hcp.questionrobot.mapper.CategoryMapper;
import didi.hcp.questionrobot.service.ICategoryService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * Service实现
 *
 * @author huchengpeng
 * @date 2021-12-11 16:42:08
 */
@Service("categoryService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public boolean addCategory(CategoryBO categoryBO) {
        final Category category = new Category();
        BeanUtils.copyProperties(categoryBO,category);
        return save(category);
    }

    @Override
    public boolean updateCategory(CategoryBO categoryBO) {
        final Category category = new Category();
        BeanUtils.copyProperties(categoryBO,category);
        return updateById(category);
    }
}
